package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.PrductionPlan;
import com.ruoyi.system.mapper.PrductionPlanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.StockMapper;
import com.ruoyi.system.domain.Stock;
import com.ruoyi.system.service.IStockService;

/**
 * 库存管理Service业务层处理
 * 
 * @author liukangzu
 * @date 2025-04-17
 */
@Service
public class StockServiceImpl implements IStockService 
{
    @Autowired
    private StockMapper stockMapper;

    @Autowired
    private PrductionPlanMapper prductionPlanMapper;

    /**
     * 查询库存管理
     * 
     * @param stockId 库存管理主键
     * @return 库存管理
     */
    @Override
    public Stock selectStockByStockId(Integer stockId)
    {
        Stock stock = stockMapper.selectStockByStockId(stockId);
        System.out.println(stock);
        return stock;
    }

    /**
     * 查询库存管理列表
     * 
     * @param stock 库存管理
     * @return 库存管理
     */
    @Override
    public List<Stock> selectStockList(Stock stock)
    {
        List<Stock> stocks = stockMapper.selectStockList(stock);
        System.out.println(stocks);
        return stocks;
    }

    /**
     * 新增库存管理
     * 
     * @param stock 库存管理
     * @return 结果
     */
    @Override
    public int insertStock(Stock stock)
    {
        prductionPlanMapper.finishPrductionPlanByPrductionPlanId(stock.getStockProductionPlanId());
        return stockMapper.insertStock(stock);
    }

    /**
     * 修改库存管理
     * 
     * @param stock 库存管理
     * @return 结果
     */
    @Override
    public int updateStock(Stock stock)
    {
        return stockMapper.updateStock(stock);
    }

    /**
     * 批量删除库存管理
     * 
     * @param stockIds 需要删除的库存管理主键
     * @return 结果
     */
    @Override
    public int deleteStockByStockIds(Integer[] stockIds)
    {
        return stockMapper.deleteStockByStockIds(stockIds);
    }

    /**
     * 删除库存管理信息
     * 
     * @param stockId 库存管理主键
     * @return 结果
     */
    @Override
    public int deleteStockByStockId(Integer stockId)
    {
        return stockMapper.deleteStockByStockId(stockId);
    }

    /**
     * 批量清理库存
     *
     * @param stockIds 需要删除的库存管理主键
     * @return 结果
     */
    @Override
    public int cleanStockByStockIds(Integer[] stockIds)
    {
        return stockMapper.cleanStockByStockIds(stockIds);
    }

    /**
     * 清理库存
     *
     * @param stockId 库存管理主键
     * @return 结果
     */
    @Override
    public int cleanStockByStockId(Integer stockId)
    {
        return stockMapper.cleanStockByStockId(stockId);
    }
}
